/**
 * @description format time
 * @author 盘古他爹
 */

// function padTime(date: number) {
//   return
// }

class Format {
  //YYYY-MM-DD HH:MM:SS

  formatTime(date: string) {
    // console.log("date", date);
    const time = new Date(date)
    const YYYY = time.getFullYear()
    const MM = (time.getMonth() + 1).toString().padStart(2, "0")
    const DD = (time.getDay() + 1).toString().padStart(2, "0")
    const hh = (time.getHours() + 1).toString().padStart(2, "0")
    const mm = (time.getMinutes() + 1).toString().padStart(2, "0")
    const ss = (time.getSeconds() + 1).toString().padStart(2, "0")

    console.log("time", `${YYYY}-${MM}-${DD} ${hh}:${mm}:${ss}`)
    return `${YYYY}-${MM}-${DD} ${hh}:${mm}:${ss}`
  }

  //格式化以逗号分隔得多个tag标签
  formatTags(tags: string) {
    // console.log("tags");

    const tagList = tags.split(",")
    return tagList
  }
}
// export new FormatTime().formatYearToSecond()

export function formatTime(date: string) {
  const time = new Date(date)
  const YYYY = time.getFullYear()
  const MM = (time.getMonth() + 1).toString().padStart(2, "0")
  const DD = (time.getDay() + 1).toString().padStart(2, "0")
  const hh = (time.getHours() + 1).toString().padStart(2, "0")
  const mm = (time.getMinutes() + 1).toString().padStart(2, "0")
  const ss = (time.getSeconds() + 1).toString().padStart(2, "0")

  console.log("time", `${YYYY}-${MM}-${DD} ${hh}:${mm}:${ss}`)
  return `${YYYY}-${MM}-${DD} ${hh}:${mm}:${ss}`
}

export default new Format()
